<template>
    <!-- <keep-alive> -->
   <div class="list">
        <div class="btn">
            <span v-for="(item,index) in btnArr" :key="index" @click="handleClick(index)" :class="{active:currentIndex == index}">{{item}}</span>
        </div>
        <div class="shop" v-for="(item,index) in ShopArr" :key="index">
            <div class="imgbox">
                <img :src="item.picture" alt="">
            </div>
            <div class="text">
                <span class="name">{{item.name}}</span>
                <div class="left">
                    <span class="id_b">爆爆团价</span>
                    <br>
                    <span class="money_1">￥<span class="money_2">{{item.min_price}}</span></span>
                    <span class="discount">{{item.promotion_info}}</span>
                </div>
                <div class="right">
                    <div class="buy" @click="BuyClick(item,index)">{{item.lq?'已抢购':'马上抢'}}</div>
                    <span class="sell">{{item.month_saled_content}}份</span>
                </div>
            </div>
        </div>
  </div>
<!-- </keep-alive> -->
  
</template>

<script>
import {tuan_list} from '../utils/api'

export default {
    data(){
        return {
            btnArr:['正在抢购','上新预告'],
            ShopArr:[],
            currentIndex:0,
        }
    },
    mounted(){
       this.beat(this.currentIndex);  
    },
    methods:{
        BuyClick(item,index){
            item.lq = true;
        },
        handleClick(index){
            this.currentIndex = index;
            this.beat(index);
        },
        beat(currentIndex){
            tuan_list({status:currentIndex}).then((res)=>{
            // console.log(res.data);
            this.ShopArr = res.data.list;
            for(let i =0;i<this.ShopArr.length;i++){
                this.$set(this.ShopArr[i],"lq",false);
            }
            // item.lq = true;
        })
        },
    },
    deactivated(){
       this.beat(this.currentIndex);  
    }
}
</script>

<style lang="scss" scoped>
.list {
    background-color: rgb(245, 245,245);
    padding-bottom: 50px;
}
.btn{
    display: block;
    float: left;
}
.btn span:nth-child(1) {
    width: auto;
    display: inline-block;
    margin-left: 10px;
    font-size: 20px;
    color: #fff;
    top: 90px;
    position: absolute;
}
.btn span:nth-child(2) {
    width: auto;
    display: inline-block;
    margin-left: 10px;
    font-size: 20px;
    color: #fff;
    top: 90px;
    left: 100px;
    position: absolute;
}
.btn span.active{
    font-weight: bolder;
    border-bottom: 4px solid #f00 ;
    color: #000;
}

// 列表图片
.shop {
    width: 95%;
    height: 150px;
    background: #fff;
    display: flex;
    border-radius:10px ;
    margin: 10px auto;
    box-shadow: 0 8px 12px #ebedf0;
}
.shop .imgbox {
    width: 130px;
    height: 130px;
    margin: 10px;
    align-items: center;
    
}
.shop .imgbox img{
    border-radius: 5px;
    width: 130px;
    height: 130px;
}

// 列表文字
.shop .text{
    width: 100%;
    margin: 10px;
    position: relative;
}
.shop .left{
    position: absolute;
    bottom: 10px;
}
.shop .text .name{
    // display: inline-block;
    // float: left;
    font-weight: bolder;
}
.shop .text .left .id_b {
    display: inline-block;
    margin-top: 30px;
    font-size: 14px;
    color: orangered;
}
// 列表金额
.shop .text .left .money_1{
    display: inline-block;
    margin-top: 5px;
    font-size: 10px;
    color: orangered;
}
.shop .text .left .money_2{
    font-size: 24px;
    padding: 2px 2px 2px 0;
    font-weight: bolder;
    color: orangered;
}
.shop .text .left .discount{
    display: inline-block;
    border: 1px solid orange;
    font-size: 14px;
    border-radius: 5px;
    color: orangered;
}
.shop .text .right {
    position: absolute;
    right: 0;
    bottom: 0;
}
.shop .text .right .buy{
    background:orangered;
    color: #fff;
    text-align: center;
    width: 80px;
    height: 30px;
    font-size: 14px;
    border-radius: 30px;
    line-height: 30px;
}
.shop .text .right .sell{
    display: inline-block;
    font-size: 12px;
    margin-top: 15px;
    margin-left: 10px;
    color: orangered;
}
</style>